/*mainwindow of this gogame app, used QT4.3.2 for this GUI design
 *contains all GUI itmes, slots can do different things if they recieve
 *signals from mainwindow itself even from mainwindow's children obj
 */

#ifndef GOMAINWINDOW_H
#define GOMAINWINDOW_H

#include <QMainWindow>

class Board;
class QAction;
class QLabel;
class QToolButton;
class QComboBox;
class QFile;
class Settings;

class GoMainWindow : public QMainWindow
{
    Q_OBJECT

public:
    GoMainWindow(); //constructor
    ~GoMainWindow();

protected:

private slots:
    void open(); //open a file in .sgf type
    bool save(); //save a file in .sgf type with the current name curFile
    bool saveAs(); //save a file in .sgf type with another name or curFile is 0
    void save2DBoard(); //output current 2D-Board array as a binary file
    void newGame(); //restart a newgame -->newAction
    void beforeClose(); //ask if you really want to quit -->exitAction
    void about(); //about this application -->aboutAction
    void startReview(); // -->startReviewAction
    void quitReview(); // -->quitReviewAction
    void trueButtonDisplay();
    void falseButtonDisplay();
    void openReview();
    void closeReview();
    void disableShowIndex();
    void enableShowIndex();
    void disableGameSettings();
    void enableGameSettings();
    void openGameSettingsDialog(); // all game Settings here, not totally complete
    void windowIsModified(); //setWindowModified(true)
    void loadSucceed(); // QMessageBox feedback if loading succeed
    void loadFailed(); // QMessageBox feedback if loading failed

    //游戏设定的相关按钮只有在初始状态下可以设置, 一旦进入游戏除了newGame以外无法点击
    //gs represents game-settings, the slots below binding Actions which in game-settings dialog
    void gs_exec(); //invoked after apply the settings
                    //save changes to obj gameSettings and emit signals to boardscene if necessary

        signals:
    /** FIXME: not only handicaps but all other settings should be passed to Core **/
    /**        that means pass pointer of Settings-obj as parameters to Core      **/
    void changeHandicaps(int); //Board-GUI changing always in boardscene
    //ioSGF operated also under boardscene cause have to call Go class and operating board-GUI
    void outputSGF(QFile*, Settings*);
    void inputSGF(QFile*, Settings*);
    void output2DBoard(const char*);

private:
    void createActions();
    void createMenus();
    void createStatusBar();
    void createToolBars();
    void createToolButtons();

    bool loadGame(const QString &filename); //do some pre-work then emit inputSGF signal
    bool saveGame(const QString &filename); //do some pre-work then emit outputSGF signal
    bool okToContinue(); //before other file operation ask if save current file
    void changeStatus(int); //change Status such as Review, Normal...

private:
    QString curFile; //name of the file which being operated atm

    int status; // 1 -> normal ; 2 -> after push startReview(init & startReview disable) ; 3 -> init enabled ; 4 -> backward disabled
                // 5 -> forward disabled ; 6 -> backward enabled ; 7 -> forward enabled ; 8 -> init disabled

    /**  Game Settings Value **/
    Settings *gameSettings;  //class save gamesettings' parameters
    QComboBox *handicapsComboBox; //make it as member obj cause we read a value from this obj
    /**  Game Settings Value **/

    Board *boardView; //centralWidget for the MainWindow

    QLabel *statusLabel; //Lable in statusBar

    QAction *newAction;
    QAction *saveAction;
    QAction *saveAsAction;
    QAction *openAction;
    QAction *output2DBoardAction;
    QAction *exitAction;
    QAction *aboutAction;
    QAction *showGridAction;
    QAction *showIndexAction;
    QAction *gameSettingsAction;

    QAction *startReviewAction;
    QAction *backToFirstAction;
    QAction *jumpBackwardAction;
    QAction *backwardAction;
    QAction *forwardAction;
    QAction *jumpForwardAction;
    QAction *goToEndAction;
    QAction *backToInitAction;
    QAction *quitReviewAction;
    QAction *regretAction;
    QAction *judgmentAction;
    QAction *passAction;
    QAction *aiMoveAction;

    QMenu *fileMenu;
    QMenu *optionMenu;
    QMenu *settingMenu;
    QMenu *helpMenu;

    QToolBar *fileToolBar;
    QToolBar *editToolBar;

    QToolButton *startReviewButton;
    QToolButton *backToFirstButton;
    QToolButton *jumpBackwardButton;
    QToolButton *backwardButton;
    QToolButton *forwardButton;
    QToolButton *jumpForwardButton;
    QToolButton *goToEndButton;
    QToolButton *backToInitButton;
    QToolButton *quitReviewButton;
    QToolButton *regretButton;
    QToolButton *judgmentButton;
    QToolButton *passButton;
    QToolButton *aiMoveButton;

};

#endif // GOMAINWINDOW_H
